<?php

class Registry {

	private static $data = array();

	static function getByRealm($realm) {

		if (!isset(self::$data[$realm]))
			return null;

		return self::$data[$realm];
	}

	static function getByName($realm, $name) {

		if (!isset(self::$data[$realm]))
			return null;

		for ($i=0; $i<sizeof(self::$data[$realm]); $i++) {
			if (self::$data[$realm][$i]->getTitle() == $name)
				return self::$data[$realm][$i];
		}

		return null;
	}

	static function register($realm, $obj) {

		$obj->setup();

		if (!isset(self::$data[$realm]))
			self::$data[$realm] = array();

		array_push(self::$data[$realm], $obj);

	}

}

?>